<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>Nagios安装 | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>Nagios安装</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Nagios/">Nagios</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a href="http://nagios.org" target="_blank" rel="external">Nagios官网</a></p>
<h2 id="1-nagios-简介"><a href="#1-nagios-简介" class="headerlink" title="1.nagios 简介"></a>1.nagios 简介</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;nagios 是一个开源软件，可以监控网络设备网络流量、linux/windows 主机状态，甚至可以监控打印机。它可以运行在 linux 上或 windows 上。基于浏览器的 web 界面方便运维人员查看监控项目的状态，支持 web 界面配置、管理操作、支持短信、邮件通知，可以自定义脚本实现自定义化监控。</p>
<h2 id="2-nagios-安装-服务端（192-168-0-62）"><a href="#2-nagios-安装-服务端（192-168-0-62）" class="headerlink" title="2.nagios 安装 - 服务端（192.168.0.62）"></a>2.nagios 安装 - 服务端（192.168.0.62）</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;首先来安装服务器，nagios 同样也是需要 apache + php 的环境，centos 6 默认的 yum 源里没有 nagios 相关的 rpm 包，需要安装一个 epel 的扩展源。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@nagios ~]<span class="comment"># yum install -y epel-release</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;然后安装 nagios 相关的包</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@nagios ~]<span class="comment"># yum install -y httpd nagios nagios-plugins nagios-plugins-all nrpe nagios-plugins-nrpe</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;设置登录 nagios 后台的用户和密码：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">[root@nagios ~]<span class="comment"># htpasswd -c /etc/nagios/passwd nagiosadmin</span></div><div class="line">New password: </div><div class="line">Re-type new password: </div><div class="line">Adding password <span class="keyword">for</span> user nagiosadmin</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;检查配置文件是否有问题</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@nagios ~]<span class="comment"># nagios -v /etc/nagios/nagios.cfg</span></div></pre></td></tr></table></figure>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/nagios%E5%AE%89%E8%A3%85/01.png?raw=true" alt=""></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;说明配置文件没有问题</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;启动服务</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@nagios ~]<span class="comment"># service httpd start</span></div><div class="line">[root@nagios ~]<span class="comment"># service nagios start</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;浏览器访问 <a href="http://ip/nagios" target="_blank" rel="external">http://ip/nagios</a></p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/nagios%E5%AE%89%E8%A3%85/03.png?raw=true" alt=""></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;输入设置的帐号密码登录</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/nagios%E5%AE%89%E8%A3%85/02.png?raw=true" alt=""></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;此时，nagios 监控的只有 localhost ，还没有其他机器，要想添加监控客户机，还需要在客户端安装 nagios 相关的软件包，并且需要在服务端配置。</p>

	

	
		<span class="different-posts"><a href="/2017/10/12/Nagios/1. Nagios 安装/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
